﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace NutriFast
{
    public partial class DietaSelPaciente : Form
    {
        DietaUpdatePacient dup;
        bool creado = false;
        public DietaSelPaciente()
        {
            InitializeComponent();
            
        }

        private void button4_Click(object sender, EventArgs e)
        {
            UsuarioAdd ua = new UsuarioAdd();
            ua.ShowDialog();
       
        }


        private void button1_Click(object sender, EventArgs e)
        {
            if (this.dataGridView1.Rows.Count == 0)
                MessageBox.Show(this, "Seleccione Paciente \n Especifique el filtro", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            else
            {

                if (this.creado == false)
                {
                    dup = new DietaUpdatePacient(this);
                    this.creado = true;
                }
                this.Hide();
                dup.name.Text = "" + this.dataGridView1.Rows[this.dataGridView1.CurrentRow.Index].Cells[1].Value;
                dup.currentpacient = (int)this.dataGridView1.Rows[this.dataGridView1.CurrentRow.Index].Cells[0].Value;
                dup.he.Value = dbVic.getPeso(dup.currentpacient);
                dup.Show();
                dup.MdiParent = this.MdiParent;
            }
        }

        private void name_TextChanged(object sender, EventArgs e)
        {
            this.spVicSerarchPatientTableAdapter.Fill(this.dsVicSearchPatient.spVicSerarchPatient, this.name.Text);
        }

        private void DietaSelPaciente_Load(object sender, EventArgs e)
        {
            name_TextChanged(null, null);
        }

        private void name_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == '\r')
                button1.PerformClick();
        }

        
    }
}
